//
//  NewsComment.swift
//  Jock
//
//  Created by HD on 15/3/19.
//  Copyright (c) 2015年 Haidy. All rights reserved.
//

import Foundation

class NewsComment {
    
    var content: String = ""
    var user: User?
    var id: String = ""
    var floor: Int = 0
    
    class func analyse(json: JSON) -> [NewsComment] {
        var comments = [NewsComment]()
        let array = json["items"]
        for (index: String, subJson: JSON) in array {
            var comment = NewsComment()
            comment.content = subJson["content"].string!
            let user = subJson["user"]
            if subJson["user"].type != Type.Null {
                comment.user = User.analyse(user)
            }
            comment.id = subJson["id"].string!
            comment.floor = subJson["floor"].intValue
            comments.append(comment)
        }
        return comments
    }
}